package com.csw.clazzTeacher.service;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.csw.clazzTeacher.dao.CityDAO;
import com.csw.clazzTeacher.entity.City;

/**
 * @author 1
 */
@Service("cityService")
@Transactional(rollbackFor = Exception.class)
public class CityServiceImpl implements CityService {

	@Autowired
	private CityDAO cityDAO;

	@Override
	public void save(City city) {
		try {
			city.setId(UUID.randomUUID().toString());
			cityDAO.save(city);
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException("添加城市失败..");
		}
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public List<City> findAll() {
		List<City> cities = cityDAO.queryAll();
		return cities;
	}

}
